<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <div id="app">
        <!-- <div>{{obj.name}} -- {{obj.age}} -- {{obj.sex}}</div> -->
        <div>{{name}} -- {{age}} -- {{sex}}</div>
        <button v-on:click="changeAge">change age</button>
    </div>


    <!-- 引入vue -->
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script>
        const { createApp, ref, reactive, toRefs } = Vue;
        // 创建Vue实例
        const app = createApp({
            setup() {
                // 基本数据类型 reactive 不支持
                // const count = reactive(2)
                const obj = reactive({
                    name: '张三',
                    age: 20,
                    sex: '男'
                })
                const changeAge = () => {
                    obj.age++
                }
                return {
                    // obj,
                    ...toRefs(obj),

                    changeAge
                }
            }
        })
        // 挂载到dom
        app.mount('#app')
    </script>
</body>

</html>